package HomeService

import (
	"context"
	"gdshop-font-api-go/app/request/HomeReq"
	"gdshop-font-api-go/library/response"
	"gdshop-font-api-go/library/wxpayHelper"
	"github.com/gogf/gf/frame/g"
)

func WechatInfo(ctx context.Context, parames *HomeReq.WechatInfo) *response.JsonResponse {
	wxoa := wxpayHelper.GetWxOa()
	url := ""
	if parames.Scope == "" || parames.Scope == "snsapi_base" {
		parames.Scope = "snsapi_base"
		url = wxoa.AuthURL("snsapi_base", parames.Uri)
	} else {
		url = wxoa.AuthURL("snsapi_userinfo", parames.Uri)
	}
	return response.SuccessByRequestMessageData(nil, "成功", g.Map{
		"appid": g.Cfg().GetString("pay.wechatpay.appId"),
		"scope": parames.Scope,
		"url":   url,
	})
}
